import {reqUserLogin,reqUserLogout} from "@/api";
import ResultUtil from '@/utils/ResultUtil'

const state = {
    isLogin:false
};
const mutations = {
    USERLOGIN(state){
        state.isLogin = true;
    },
    LOGOUT(state){
        state.isLogin = false;
    }
};
const actions = {

    async userLogin({commit},user){
        let result = await reqUserLogin(user)
        if(ResultUtil.isSuccess(result)){
            commit("USERLOGIN");
        }
        return result;
    },
    userLogout({commit}){
        reqUserLogout();
        commit("LOGOUT");
    },
};
const getters = {};

export default {
    state,
    mutations,
    actions,
    getters
}
